//
//  ViewController.m
//  TopRightPopover
//
//  Created by Burn on 2019/1/11.
//  Copyright © 2019 nmgxysh. All rights reserved.
//

#import "ViewController.h"
#import "TopRightPopover.h"

@interface ViewController ()

/**Popover*/
@property(weak,nonatomic) TopRightPopover *popover;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    //[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(right)];
    self.navigationController.navigationBar.translucent = NO;
    
}

- (void)right{
    TopRightPopover *popover = [[TopRightPopover alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 105,5, 100, 150)];
    [self.view addSubview:popover];
    [popover animation];
    self.popover = popover;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.popover removeFromSuperview];
    self.popover = nil;
}

@end
